import BaseController from '../../core/controllers/Base.controller';

@Inject('$log', '$rootScope', '$state', 'globalService', 'personalWorkbenchService', 'ngDialog', 'ngDialogService')
class PersonalWorkbenchDoneController extends BaseController {
  constructor() {
    super(personalWorkbenchService, 'queryDone');

    this.paginationService = this.personalWorkbenchService;
    this.$setQueryCallback((res) => {
      this.doneListData = res.rows;
    });
    this.$paginationQuery();
  }

  $query(param) {
    if (param && param.createStartTime.$valid && param.createEndTime.$valid
      && param.createStartTime.$viewValue > param.createEndTime.$viewValue) {
      this.ngDialogService.alertError('创建时间开始时间应小于结束时间');
      return;
    }
    this.$paginationQuery();
  }

  $reset() {
    this.mapParams = {};
  }
}

export default PersonalWorkbenchDoneController;
